<template>
  <div class="login">
    <div class="login-1">
      <div class="img">
      <img src="./img/4.jpg" alt />
    </div>
    <div class="login-rule">
      <el-form
      :model="ruleForm"
      :rules="rules"
      ref="ruleForm"
      label-width="100px"
      class="demo-ruleForm"
    >
      <el-form-item label="用户名" prop="username">
        <el-input v-model="ruleForm.username"></el-input>
      </el-form-item>
      <el-form-item label="密码" prop="password">
        <el-input v-model="ruleForm.password"></el-input>
      </el-form-item>
      <el-form-item class="button">
        &emsp;&emsp;
        <el-button type="primary" @click="submitForm"
          >登录</el-button
        >
        &emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;
        <el-button @click="resetForm">注册</el-button>
      </el-form-item>
    </el-form>
    </div>
    </div>
  </div>
</template>

<script>
import { mapState,mapActions } from 'vuex'
export default {
  data() {
    return {
      ruleForm: {
          username:"",
          password:""
        },
        rules: {
          username: [
            { required: true, message: '请输入用户名', trigger: 'blur' },
          ],
          password:[
            { required: true, message: '请输入密码', trigger: 'blur' },
          ]
        }
    };
  },
  methods: {
    ...mapActions(["userlogin", "resgister"]),
    submitForm() {
      this.userlogin(this.ruleForm);
    },
    resetForm() {
      this.resgister(this.ruleForm);
    }
  }
};
</script>

<style scoped>
.login {
  width: 500px;
  height: 100%;
  background-image: url("https://img2.baidu.com/it/u=967785925,2697253210&fm=26&fmt=auto&gp=0.jpg");
  background-repeat: no-repeat;
  background-size: 100% 100%;
  height: 100%;
  position: fixed;
  width: 100%;
}
.img {
  display: flex;
  align-content: center;
}
.login-1{
  margin-top: 100px;
}
.img img {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  /* margin-left: 750px; */
  margin: 10px auto;
}
.login-rule {
  width: 500px;
  height: 200px;
  background: initial;
  margin: 20px auto;
  border: 1px solid #c6e5f1;
  background: linear-gradient(45deg, #f5f5ee, #f5ddf2);
  /* box-shadow:4px 2px 6px #929191;  */
  box-shadow:4px 2px 6px #f7f6d7, -4px -2px 6px #e7f5f0;

  border-radius: 5px;
}
.login-rule .demo-ruleForm{
  margin-top: 20px;
  margin-left: -20px;
}
.login-rule .demo-ruleForm .button{
  display: flex;
}
</style>